package com.alibaba.demo.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author zhouyanxiang
 * @create 2020-08-2020/8/24-16:46
 */
@WebFilter(filterName = "ayUserFilter" , urlPatterns = "/*")
public class AyUserFilter implements Filter {

    private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());

    @Override
    public void init(FilterConfig filterConfig) throws ServletException{
//        System.out.println("----------> init");
        LOGGER.info("----------> init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        System.out.println("----------> doFilter" );
        LOGGER.info("----------> doFilter");
        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy(){
        LOGGER.info("----------> destroy");
//        System.out.println("----------> destroy");
    }
}

